package com.xs.bookspoststation.UserActivity2;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

import com.xs.bookspoststation.BookActivity.FindBookActivity;
import com.xs.bookspoststation.R;
import com.xs.bookspoststation.UserActivity.MainActivity;

public class UserOperateInfoActivity extends AppCompatActivity {
    //定义对象
    private Button btn_sel_book1,btn_my_borrow,btn_update_pass1,btn_back3;
    TextView welcomeName;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_user_operate_info);
        //绑定控件
        btn_sel_book1 = findViewById(R.id.btn_sel_book1);
        btn_my_borrow = findViewById(R.id.btn_my_borrow);
        btn_update_pass1 = findViewById(R.id.btn_update_pass1);
        welcomeName=(TextView)findViewById(R.id.user_textView1);
        btn_back3 = findViewById(R.id.btn_back3);

        //先把Login传过来的username和userpwd接收
        Intent intent=getIntent();
        final String Myname = intent.getStringExtra("username");//当前用户的账号和密码
        final String MyPassword = intent.getStringExtra("userpwd");
        welcomeName.setText(Myname);//显示登录用户名

        //查找书籍按钮
        btn_sel_book1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent();
                Bundle bundle=new Bundle();
                bundle.putString("username", Myname);
                intent.putExtras(bundle);
                intent.setClass(getApplicationContext(), FindBookActivity.class);
                startActivity(intent);
                Toast.makeText(UserOperateInfoActivity.this, "查找书籍", Toast.LENGTH_LONG).show();
            }
        });
        //我的借阅
        btn_my_borrow.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

            }
        });
        //修改密码按钮
        btn_update_pass1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent2 = new Intent(UserOperateInfoActivity.this,UpdateUserPwdActivity.class);
                startActivity(intent2);
            }
        });
        //退出按钮
        btn_back3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent3 = new Intent(UserOperateInfoActivity.this, MainActivity.class);
                startActivity(intent3);
            }
        });
    }
}
